package priv.pront.code.lanqiao.competition.course.date0329;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
// fixme score 40
public class 差为给定的数 {
    static int N, C, count = 0, left, right;
    static Set<Integer> set = new HashSet<>();
    static int[] arr;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        C = scanner.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = scanner.nextInt();
        }
        Arrays.sort(arr);
        for (int i = N - 1; i > 0; i--) {
            right = i - 1;
            left = 0;
            while (left <= right) {
                int mid = left + (right - left) / 2;
                if (arr[i] - arr[mid] > C) {
                    left = mid + 1;
                } else if (arr[i] - arr[mid] < C) {
                    right = mid - 1;
                }else if (arr[i] - arr[mid] == C && !set.contains(mid)) {
                    left = mid + 1;
                    set.add(mid);
                    count++;
                }
            }
            set.removeAll(set);
        }
        System.out.println(count);
    }
}
